function [wvector,Gvector]=main_quantiles2(G,w,n);


pctiles=[0.10,0.25,0.50,0.75,0.90]; 
    wvector=[];
    Gvector=[];

 for q=1:5
    iter=0;
    for i=1:n
            dG=G(i)-pctiles(q);
            iter=iter+1;
            crit_q(iter)=abs(dG/pctiles(q));
           end
    index_q=min(find(crit_q<=min(crit_q)));
    w_q= w(index_q);
    G_q= G(index_q);
    wvector=[wvector;w_q];
    Gvector=[Gvector;G_q];
end


  


